var React = require('react');


var Bheader = require('../widget/Bheader');
var Footer = require('../widget/Footer');
var GT = require('../components/GT');

module.exports = React.createClass({
    getInitialState: function () {
        return {
            theme:"Default",
            title:"产品追溯"
        }
    },
    componentDidMount: function () {

    },
    /**验证URL*/
    IsValidUrl(str){
        var regu = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
        var re = new RegExp(regu);
        console.log(str);
        console.log(re.test(str));
        if(re.test(str)){
            return true;
        }else{
            return false;
        }
    },

    render: function () {
        var p = this,
            url = localStorage.getItem("ewm");
        var urlFlag = this.IsValidUrl(url);
        console.log(urlFlag);
        return (
            <div className="main"  id="main">
                <Bheader theme={this.state.theme} headr="false" title={p.state.title} hact="#"></Bheader>
                <div id="QRWrapper" className="container-t noFooter">
                    {urlFlag?
                        <iframe src={url} className="ewm" style={{width:"100%",minHeight:"31.15rem",border:"none"}}>
                            <p>您的浏览器不支持iframe标签。</p>
                        </iframe>:<div>{url}</div>
                    }
                </div>
            </div>
        )
    }
});
